package com.ziytek.web.citizen.model.rsp;

import com.ziytek.web.citizen.constant.ServerConstant;
import com.ziytek.web.citizen.enums.ResponseEnum;
import com.ziytek.web.citizen.model.vo.CapDetailVo;
import lombok.Data;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 电池容量详情数据查询响应结果
 *
 * @className CapDetailQueryRsp
 * @description: 描述
 * @jdkVersion: 1.8
 * @author: fhx
 * @date: 2024/7/2 9:53
 */
@Data
public class CapDetailQueryRsp {
    /**
     * 返回编码
     */
    private String retCode;

    /**
     * 编码描述
     */
    private String retMsg;

    /**
     * 总页数
     */
    private Integer pageCount;

    /**
     * 数据总数
     */
    private Integer dataCount;

    /**
     * 批次列表数据
     */
    private List<CapDetailVo> data;

    public void setCapDetailVo(CapDetailVo vo) {
        if (vo == null) {
            return;
        }
        if (CollectionUtils.isEmpty(data)) {
            data = new ArrayList<>();
        }
        data.add(vo);
    }


    public void setRetErrorData(String retMsg) {
        this.retMsg = retMsg;
        this.retCode = ServerConstant.ERROR;
        this.pageCount = 0;
        this.dataCount = 0;
    }

    public void setRetSuccessData(int pageCount, int dataCount) {
        this.pageCount = pageCount;
        this.dataCount = dataCount;
        this.retCode = ServerConstant.SUCCESS;
        this.retMsg = ResponseEnum.SUCCESS.getDesc();
    }
}
